@extends('layouts.tankuang')

@section('content')
<style type="text/css">
	.pagination-info {margin-right: 16px;}
</style>
    <div id="menu">
        <a class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add_faren()">新增</a>
        <a class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit_faren()">编辑</a>
        <a class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="del_faren()">删除</a>
    </div>
    <table id="faren_form" title="" class="easyui-datagrid" style="width:100%;height:596px"
           data-options="rownumbers:true,border:false,singleSelect:true,pagination:true,pageSize:20,url:'{{url('admin/baoan/guanli',$id)}}',method:'get',toolbar:'#menu'">
        <thead>
        <tr>
            <th data-options="field:'name'" width="10%" align="center">姓名</th>
            <th data-options="field:'sex'" width="10%" align="center">性别</th>
            <th data-options="field:'birthday'" width="10%" align="center">出生年月</th>
            <th data-options="field:'nation'" width="10%" align="center">民族</th>
            <th data-options="field:'native_place'" width="10%" align="center">籍贯</th>
            <th data-options="field:'education'" width="10%" align="center">文化程度</th>
            <th data-options="field:'political_status'" width="10%" align="center">政治面貌</th>
            <th data-options="field:'phone'" width="10%" align="center">联系电话</th>
            <th data-options="field:'updated_at'" width="20%" align="center">修改时间</th>
        </tr>
        </thead>
    </table>

    <div id="baoan" class="easyui-window" closed="true" title="新增" data-options="iconCls:'icon-save'"></div>

    <div id="del_faren" class="easyui-dialog" title="注销" closed="true" style="width:400px;height:200px;line-height:100px;text-align:center;font-size:16px;padding:10px">
        您确定要删除该记录？
    </div>
    <script type="text/javascript" src="{{ URL::asset('/') }}js/weizhi.js"></script>
    <script type="text/javascript">
    	var shuz = fb2();
        function add_faren(){
        	var shuz = fb2();
            $('#baoan').window({
                title: "添加",
                href: "{{url('admin/baoan/add_guanli',$id)}}",
                width:shuz[0],
				height:shuz[1],
				top:shuz[2],
				left:shuz[3],
                minimizable:false,
                modal:true,
                closed: false,
            });
        }
        function edit_faren(){
        	var shuz = fb2();
            var row = $('#faren_form').datagrid('getSelected');
            if (row) {
                var url = "{{url('admin/baoan/edit_guanli')}}"+"/"+row.id;
                $('#baoan').window({
                    title: "编辑",
                    href: url,
                    width:shuz[0],
					height:shuz[1],
					top:shuz[2],
					left:shuz[3],
	                minimizable:false,
                    modal:true,
                    closed: false,
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }
        function del_faren(){
            var row = $('#faren_form').datagrid('getSelected');
            if (row) {
                $('#del_faren').dialog({
                    title: "删除",
                    closed: false,
                    modal:true,
                    top:($(window).height() - 200) * 0.5,
                    left:($(window).width() - 400) * 0.5,
                    buttons: [{
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: del
                    }, {
                        text: '取消',
                        iconCls: 'icon-cancel',
                        handler: function () {
                            $('#del_faren').dialog('close');
                        }
                    }]
                });
            } else {
                $.messager.alert('提示','请选中要编辑的行！');
            }
        }

        function del(){
            $('#del_faren').dialog('close');
            var row = $('#faren_form').datagrid('getSelected');
            var url = "{{url('admin/baoan/del_guanli')}}"+"/"+row.id;
            $.ajax({
                type: 'get',
                url: url,
                success: function(data){
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                        var rowIndex = $('#faren_form').datagrid('getRowIndex', row);
                        $('#faren_form').datagrid('deleteRow', rowIndex);
                    }
                    else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        }
        $("#faren_form").datagrid({
            onDblClickRow: function (index, row) {
                edit_faren();
            }
        });

    </script>
@stop

